var checkbox = document.getElementsByClassName('checkbox');
// function register() {
//   var name = document.querySelector('#username').value
//   var pwd = document.querySelector('#pwd').value
//   var phonenumber = document.querySelector('#phonenumber').value
//   //1.通过AJAX访问服务器接口，进行注册
//   $.ajax({
//     url: 'http://localhost:3000/api/register',
//     type: 'post',
//     data: { userName: name, userPwd: pwd ,userMobile: phonenumber},
//     success: function (result) {
//       if (result.message == 'ok') {
//         //2.跳转到登录页面
//         alert('注册成功！')
//         location.href = 'login.html'
//       } else {
//         alert('注册失败！')
//       }
//     }
//   })
//   // if (checkbox[0].checked == true) {
//   //   alert("注册成功！");
//   //   window.location.href = "login.html"
//   // }
//   // else {
//   //   alert("请先阅读并同意《用户注册协议》！")
//   // }
// }
function checkAll() {
  return checkUser();
}
function checkUser() {
  var reg = /^[a-zA-Z][a-zA-Z0-9]{3,15}$/;
  var value = document.getElementById("username").value;
  if (reg.test(value) == false) {
    document.getElementById("userInfo").innerHTML = "<img src='images/cha.webp' width='15'/>";
    return false;
  }
  else {
    document.getElementById("userInfo").innerHTML = "<img src='images/gou.webp' width='15'/>";
    return true;
  }
}
function checknumber() {
  var reg = /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/;
  var value = document.getElementById("phonenumber").value;
  if (reg.test(value) == false) {
    document.getElementById("numberInfo").innerHTML = "<img src='images/cha.webp' width='15'/>";
    return false;
  }
  else {
    document.getElementById("numberInfo").innerHTML = "<img src='images/gou.webp' width='15'/>";
    return true;
  }
}
function checkpwd() {
  var reg = /^(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9~!@&%#_]{8,16}$/;
  var value = document.getElementById("pwd").value;
  if (reg.test(value) == false) {
    document.getElementById("pwdInfo").innerHTML = "<img src='images/cha.webp' width='15'/>";
    return false;
  }
  else {
    document.getElementById("pwdInfo").innerHTML = "<img src='images/gou.webp' width='15'/>";
    return true;
  }
}
function checkrepwd() {
  if (document.getElementById('c_pwd').value != document.getElementById('pwd').value) {
    document.getElementById("c_pwdInfo").innerHTML = "<img src='images/cha.webp' width='15'/>";
  }
  else {
    document.getElementById("c_pwdInfo").innerHTML = "<img src='images/gou.webp' width='15'/>";
    return true;
  }
}

// var verifyCode = new GVerify("vCodeImg");
// // console.log(verifyCode.options.code);
// function checkverify() {
//   var a = document.getElementById('verify').value;
//   if (a != verifyCode.options.code) {
//     document.getElementById("c_pwdInfo").innerHTML = "<img src='images/cha.webp' width='15'/>";
//   } else {
//     document.getElementById("verify").innerHTML = "<img src='images/gou.webp' width='15'/>";
//     return true;
//   }
// }